package cn.sharp.bbs.controller;


import cn.sharp.bbs.common.Result;
import cn.sharp.bbs.entity.BO.CurrentUser;
import cn.sharp.bbs.entity.BO.InteractEntity;
import cn.sharp.bbs.service.InteractService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/interact")
public class InteractController {

    @Resource
    private InteractService interactService;

    @PostMapping("/likePost")
    public Result likePost(@RequestBody InteractEntity interactEntity, @RequestAttribute("CurrentUser") CurrentUser currentUser) {
        interactService.likePost(interactEntity.getPostId(), currentUser.getU_id());
        return Result.success();
    }

    @PostMapping("/collectPost")
    public Result collectPost(@RequestBody InteractEntity interactEntity, @RequestAttribute("CurrentUser") CurrentUser currentUser) {
        interactService.collectPost(interactEntity.getPostId(), currentUser.getU_id());
        return Result.success();
    }

    @PostMapping("/followPost")
    public Result followPost(@RequestBody InteractEntity interactEntity, @RequestAttribute("CurrentUser") CurrentUser currentUser) {
        interactService.followPost(interactEntity.getPostId(), currentUser.getU_id());
        return Result.success();
    }
}
